<?php

$SQL = mysql_query("select member.intid_dealer, member.strkode_dealer, member.strnama_dealer, sum(nota.inttotal_omset)as inttotal_omset 
from member left join nota on nota.intid_dealer = member.intid_dealer
where member.strkode_upline='M21001706' 
group by member.intid_dealer");
//$Query = $conn->query($SQL);
if($Query->size()>0){
while($Query->next()){
$id = $Query->get(0);
$parent_id = $Query->get(1);
$title = $Query->get(2);
$url = $Query->get(3);
$menu_order = $Query->get(4);

$data[$parent_id][] = array("id" => $id,
  "title" => $title,
  "url" => $url,
  "menu_order" => $menu_order,
  );
}
//$conn->disconnect();
$content = '<br style="clear:left;" />';
$content .= get_menu($data);
$content .= '<br style="clear:left;" />';
}
function get_menu($data, $parent = 0) {
global $conn,$CONF;
static $i = 1;
$tab = str_repeat("\t\t", $i);
if ($data[$parent]) {
$html = "\n$tab<ul>";
$i++;
for($c=0;$c<count($data[$parent]);$c++){
$child = get_menu($data, $data[$parent][$c]["id"]);
$html .= "\n\t$tab<li>";
if(strpos($data[$parent][$c]["url"],"window")===false){
$html .= '<a href="'.$data[$parent][$c]["url"].'">'.$data[$parent][$c]["title"].'</a>';
}
else{
$html .= '<a href="javascript:void(0);" onclick="'.$data[$parent][$c]["url"].'">'.$data[$parent][$c]["title"].'</a>';
}
if ($child) {
$i--;
$html .= $child;
$html .= "\n\t$tab";
}
$html .= '</li>';
}
$html .= "\n$tab</ul>";
return $html;
}
else
{
$html="";
}
return false;
}
?>